﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EbayMaster
{
   public partial class FrmItemStat : Form
   {
      public FrmItemStat()
      {
         InitializeComponent();
      }

      private void FrmItemStat_Load(object sender, EventArgs e)
      {
         SetupDataGridViewColumns();

         this.dataGridViewAllItems.AutoGenerateColumns = false;

         DataTable dt = ItemDAL.GetAllItems();
         this.dataGridViewAllItems.DataSource = dt;
      }

      private void SetupDataGridViewColumns()
      {
          // ItemSKU
          DataGridViewTextBoxColumn itemSKUCol = new DataGridViewTextBoxColumn();
          itemSKUCol.DataPropertyName = "ItemSKU";
          itemSKUCol.HeaderText = @"商品SKU";
          itemSKUCol.ValueType = typeof(string);
          itemSKUCol.Width = 100;
          itemSKUCol.Frozen = true;
          this.dataGridViewAllItems.Columns.Add(itemSKUCol);

         // ItemName
         DataGridViewTextBoxColumn itemNameCol = new DataGridViewTextBoxColumn();
         itemNameCol.DataPropertyName = "ItemName";
         itemNameCol.HeaderText = @"商品名称";
         itemNameCol.ValueType = typeof(string);
         itemNameCol.Width = 180;
         itemNameCol.Frozen = true;
         this.dataGridViewAllItems.Columns.Add(itemNameCol);

         // ItemStockNum
         DataGridViewTextBoxColumn itemStockNumCol = new DataGridViewTextBoxColumn();
         itemStockNumCol.DataPropertyName = "ItemStockNum";
         itemStockNumCol.HeaderText = @"当前库存";
         itemStockNumCol.ValueType = typeof(int);
         itemStockNumCol.Width = 60;
         itemStockNumCol.Frozen = true;
         this.dataGridViewAllItems.Columns.Add(itemStockNumCol);

         // ItemStockShresholdNum
         DataGridViewTextBoxColumn itemStockShresholdNumCol = new DataGridViewTextBoxColumn();
         itemStockShresholdNumCol.DataPropertyName = "ItemStockShresholdNum";
         itemStockShresholdNumCol.HeaderText = @"库存报警值";
         itemStockShresholdNumCol.ValueType = typeof(int);
         itemStockShresholdNumCol.Width = 90;
         itemStockShresholdNumCol.Frozen = true;
         this.dataGridViewAllItems.Columns.Add(itemStockShresholdNumCol);

         // ItemCost
         DataGridViewTextBoxColumn itemPriceCol = new DataGridViewTextBoxColumn();
         itemPriceCol.DataPropertyName = "ItemCost";
         itemPriceCol.HeaderText = @"价格￥";
         itemPriceCol.ValueType = typeof(double);
         itemPriceCol.Width = 70;
         itemPriceCol.Frozen = true;
         this.dataGridViewAllItems.Columns.Add(itemPriceCol);

         // ItemWeight
         DataGridViewTextBoxColumn itemWeightCol = new DataGridViewTextBoxColumn();
         itemWeightCol.DataPropertyName = "ItemWeight";
         itemWeightCol.HeaderText = @"重量g";
         itemWeightCol.ValueType = typeof(double);
         itemWeightCol.Width = 60;
         itemWeightCol.Frozen = true;
         this.dataGridViewAllItems.Columns.Add(itemWeightCol);

         // ItemCustomName
         DataGridViewTextBoxColumn itemCustomNameCol = new DataGridViewTextBoxColumn();
         itemCustomNameCol.DataPropertyName = "ItemCustomName";
         itemCustomNameCol.HeaderText = @"商品报关名";
         itemCustomNameCol.ValueType = typeof(string);
         itemCustomNameCol.Width = 200;
         itemCustomNameCol.Frozen = true;
         this.dataGridViewAllItems.Columns.Add(itemCustomNameCol);

         this.dataGridViewAllItems.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
         this.dataGridViewAllItems.MultiSelect = true;
         //this.dataGridViewAllItems.RowPrePaint += new DataGridViewRowPrePaintEventHandler(dgv_RowPrePaint);

      }
   }
}
